package com.zsk.shop.config.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author yuwenbo
 * @description:
 * @date 2019-05-25 12:44
 */
@Configuration
@Slf4j
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public HandlerInterceptor getInterceptor() {
        return new LoginInterceptor();
    }

    /**
     * 登录拦截
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/swagger-resources/**",
                        "/webjars/**",
                        "/v2/**",
                        "/swagger-ui.html/**",
                        "/error",
                        "/app/luckyDraw/**",
                        "/safe/safeLimit/limit.do",
                        "/doc.html",
                        "/druid/**",
                        "/druid/");
        log.info("初始化拦截设置触发");
    }

}
